<template>
  <div class="inbound-container">
    <el-form :inline="true" label-width="120px" :model="form">
      <el-form-item label="到货编码：">
        <div class="item">{{ form.Code }}</div>
      </el-form-item>
      <el-form-item label="到货名称：">
        <div class="item">{{ form.FullName }}</div>
      </el-form-item>
      <el-form-item label="采购订单号：">
        <div class="item">{{ form.PONo }}</div>
      </el-form-item>
      <el-form-item label="确认时间：">
        <div class="item">{{ form.ACDate }}</div>
      </el-form-item>
      <el-form-item label="确认描述：">
        <div>{{ form.ACDescribe }}</div>
      </el-form-item>
    </el-form>
    <el-table ref="multipleTable" border :data="tableData">
      <el-table-column label="批次号" min-width="100" prop="BatchNo" />
      <el-table-column label="物资编码" min-width="100" prop="ItemCode" />
      <el-table-column label="物资名称" min-width="120" prop="ItemName" />
      <el-table-column label="物料规格" min-width="120" prop="ItemSepc" />
      <el-table-column label="单位" min-width="80" prop="Unit" />
      <el-table-column label="数量" min-width="80" prop="Qty" />
      <el-table-column label="单价" min-width="80" prop="UnitPrice" />
      <el-table-column label="金额" min-width="80" prop="Amt" />
      <el-table-column label="实际数量" min-width="100" prop="ConfirmQty" />
      <el-table-column label="描述" min-width="110" prop="ItemDescription" />
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        :current-page="pageNo"
        :layout="'total, sizes, prev, pager, next, jumper'"
        :page-size="pageSize"
        :total="total"
        @current-change="handleCurrentchiled"
        @size-change="handleSizechiled"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import { ArrivalConfirmDetail } from '@/api/form'

  const props = defineProps<{
    id: string
  }>()

  const form: any = ref({})
  const tableData: any = ref([])
  const id: any = props.id || ''
  const pageNo = ref(1)
  const pageSize = ref(10)
  const total = ref(0)
  const getTableData = async () => {
    const params = {
      pageNo: 1,
      pageSize: 10,
      total: 0,
      tableName: '',
      sort: '',
      order: '',
      wheres: '',
      export: true,
      value: id,
    }
    const data = await ArrivalConfirmDetail(params)
    tableData.value = data.rows || []
    form.value = data.master || {}
  }
  const handleCurrentchiled = (val: number) => {
    pageNo.value = val
  }
  const handleSizechiled = (val: number) => {
    pageSize.value = val
  }

  onMounted(() => {
    getTableData()
  })
</script>

<style lang="scss" scoped>
  .inbound-container {
    .item {
      width: 160px;
    }
  }
</style>
